//
//  YRJSearchResultPostsTableViewCell.m
//  YanRenjie
//
//  Created by dllo on 15/11/4.
//  Copyright (c) 2015年 yanrenjie. All rights reserved.
//

#import "YRJSearchResultPostsTableViewCell.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@implementation YRJSearchResultPostsTableViewCell
- (void)dealloc {
    [_photoImageView release];
    [_titleLabel release];
    [_usernameLabel release];
    [_lastpostLabel release];
    [_viewsLabel release];
    [_replysLabel release];
    
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell {
    self.photoImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.photoImageView];
    [_photoImageView release];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    [_titleLabel release];
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    self.titleLabel.numberOfLines = 2;
    
    self.usernameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.usernameLabel];
    [_usernameLabel release];
    self.usernameLabel.font = [UIFont systemFontOfSize:12];
    
    self.lastpostLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.lastpostLabel];
    [_lastpostLabel release];
    self.lastpostLabel.font = [UIFont systemFontOfSize:12];
    
    self.viewsLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.viewsLabel];
    [_viewsLabel release];
    self.viewsLabel.font = [UIFont systemFontOfSize:10];
    
    self.replysLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.replysLabel];
    [_replysLabel release];
    self.replysLabel.font = [UIFont systemFontOfSize:10];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.photoImageView.frame = CGRectMake(10, 5, (WIDTH - 20) / 3, HEIGHT - 10);
    self.titleLabel.frame = CGRectMake((WIDTH - 20) / 3 + 20, 5, (WIDTH - 20) / 3 * 2 - 10, (HEIGHT - 10) / 2);
    self.usernameLabel.frame = CGRectMake((WIDTH - 20) / 3 + 20, (HEIGHT - 10) / 2 + 5, ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 4);
    self.lastpostLabel.frame = CGRectMake((WIDTH - 20) / 3 + 20 + ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 2 + 5, ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 4);
    self.viewsLabel.frame = CGRectMake((WIDTH - 20) / 3 + 20, (HEIGHT - 10) / 2 + 5 + (HEIGHT - 10) / 4, ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 4);
    self.replysLabel.frame = CGRectMake((WIDTH - 20) / 3 + 20 + ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 2 + 5 + (HEIGHT - 10) / 4, ((WIDTH - 20) / 3 * 2 - 10) / 2, (HEIGHT - 10) / 4);     
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

